﻿window.onload = function(){
	//1.获取节点
    //	轮播广告
	var picBox = document.getElementById("picBox");
	var imgs = picBox.getElementsByTagName("img");
    var scrUl = document.getElementById("scrUl");
    var lis = scrUl.getElementsByTagName("li");
    //  书讯快递
    var flashUl = document.getElementById("flashUl");
    var fLis = flashUl.getElementsByTagName("li");
    var btnImg = document.getElementById("btnImg");
    var scroll_banner = document.getElementById("scroll_banner");
    // 最新关注
    var news = document.getElementById("news");
    var bookBox = news.getElementsByClassName("book_box");
    var newsUl = document.getElementById("newsUl");
    var newsLi = newsUl.getElementsByTagName("li");
    console.log(newsLi);//检测节点是否被获取
   //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++轮播图
    //2.封装函数
    function fHan(n1,n2,n3){
    	for(var i=0;i<n1.length;i++){
		 n1[i].style.display = "none";
		 n2[i].style.background = "#fff";
   	     n2[i].style.color = "#000";  
	   }
         n1[n3].style.display = "block";
         n2[n3].style.background = "orange";
   	     n2[n3].style.color = "#fff";
    }
    //申明一个变量来索引图片
    var index = 0;
    function scroll(){
    	index++;
       if(index == 6){
      	index = 0;
        }
      	//1.隐藏所有的图片 显示需要显示的当前图片
        fHan(imgs,lis,index);
    }
    //3.加定时器
    var t = setInterval(scroll,1000);
    //4.鼠标移入的事件
    picBox.onmouseover = function(){
    	clearInterval(t);
    }
    //5.鼠标移出的事件
    picBox.onmouseout = function(){
    	t = setInterval(scroll,1000); 
    }
    //6.小圆点
     for(var j=0;j<lis.length;j++){
     	//给小圆点对象自定义属性suoYin，将j的值赋值给它
     	lis[j].suoYin = j;
     	lis[j].onmouseover = function(){
     		index = this.suoYin;
     	//1.隐藏所有的图片 显示需要显示的当前图片
         fHan(imgs,lis,index);
     	}
     }
//书讯快递
    var indexs = 0;
   // function lunB(){
	//for(var x=0; x<fLis.length;x++){
		//indexs++;
		//if(indexs == 19){
      	  // indexs = 0;
       // }
	//fLis[x].style.display = "none";
	//}
	//fLis[indexs].style.display = "block";
    //}
   // setInterval(lunB,500);
//广告图片点击按钮隐藏图片
    btnImg.onclick = function(){
     	scroll_banner.style.display = "none";
     }
//最新关注
     //隐藏所有的展示书
     function gun(){
     	for(var y=0;y<bookBox.length;y++){
     	bookBox[y].style.display = "none";
     	newsLi[y].style.color = "#000";
     	newsLi[y].style.fontWeight = "normal";
     	newsLi[y].style.background = "url(images/dd_book_bg1.jpg)";
     }
     	//显示当前的展示书
        bookBox[indexs].style.display = "block";
        newsLi[indexs].style.color = "#882D00";
        newsLi[indexs].style.fontWeight = "bold";
        newsLi[indexs].style.background = "url(images/dd_book_bg2.jpg)";
     }
     
     for(var y=0;y<bookBox.length;y++){
     	indexs++;
		if(indexs == 4){
      	   indexs = 0;
        }
		gun();
     }
       for(var a=0;a<newsLi.length;a++){
     	//给导航对象自定义属性suoYin，将a的值赋值给它
	     	newsLi[a].suoYin = a;
	     	newsLi[a].onclick = function(){
	     	indexs = this.suoYin;	
	        gun();
           }
        }
         for(var a=0;a<newsLi.length;a++){
     	//给导航对象自定义属性suoYin，将a的值赋值给它
	     	newsLi[a].suoYin = a;
	     	newsLi[a].onmouseover = function(){
	     	indexs = this.suoYin;	
	        gun();
          }
        }
     //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++书讯快递
     
}//加载函数

